﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Data.Entity;
using Poco;

namespace WebApp
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "commander", // Route name
                "Serveur/HomeWithServeur/{email}", // URL with parameters
                new { controller = "Serveur", action = "HomeWithServeur", email = UrlParameter.Optional } // Parameter defaults
            );

            routes.MapRoute(
                "ValidNotif", // Route name
                "Serveur/ValidNotif/{id}", // URL with parameters
                new { controller = "Serveur", action = "ValidNotif", id = UrlParameter.Optional } // Parameter defaults
            );

            routes.MapRoute(
                "Home", // Route name
                "list/{type}", // URL with parameters
                new { controller = "Home", action = "Listplats" } // Parameter defaults
            );
            routes.MapRoute(
                "Home/Commander", // Route name
                "Home/AjouterPlat/{id}", // URL with parameters
                new { controller = "Home", action = "AjouterPlat", id = UrlParameter.Optional } // Parameter defaults
            );
            routes.MapRoute(
                "Home/Commander/id", // Route name
                "Home/Commander/{id}", // URL with parameters
                new { controller = "Home", action = "Commander", id = UrlParameter.Optional } // Parameter defaults
            );

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Account", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );
        }

        protected void Application_Start()
        {
            //Ajout des données de base dans la DB
            //InitDB.Seed();

            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

        }
    }
}